<template>
  <div style="padding: 20px">
    <el-row>
      <el-col :span="8">
        <div class="flex items-center" style="display: flex;align-items: center">
          <el-select v-model="queryParam.searchType" clearable>
            <el-option value="" label="全部">全部</el-option>
            <el-option value="biao_ti" label="标题"></el-option>
            <el-option value="zheng_wen" label="正文"></el-option>
            <el-option value="wen_hao" label="文号"></el-option>
            <el-option value="ji_gou" label="机构"></el-option>
            <el-option value="mo_kuai" label="模块"></el-option>
          </el-select>
          <el-input v-model="queryParam.keyword" placeholder="请输入关键字" clearable></el-input>
        </div>
      </el-col>
      <el-col :span="8">
        <el-button type="default" icon="el-icon-search" @click="handlerSearch"></el-button>
        <el-button type="primary" icon="el-icon-add" @click="handlerAdd">添加</el-button>
      </el-col>
      <el-col :span="24" style="margin-top: 10px">
        <el-table
          :data="tableData"
          style="width: 100%"
        >
          <el-table-column
            show-overflow-tooltip
            label="ID"
          >
            <template #default="{row}">
              {{ row.id }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="标题"
          >
            <template #default="{row}">
              {{ row.title }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="模块"
          >
            <template #default="{row}">
              {{ row.type }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="文号"
          >
            <template #default="{row}">
              {{ row.articleNo }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="文号"
          >
            <template #default="{row}">
              {{ row.indexNo }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="发文机构"
          >
            <template #default="{row}">
              {{ row.department }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="文档地址"
          >
            <template #default="{row}">
              {{ row.docUrl }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="pdf地址"
          >
            <template #default="{row}">
              {{ row.pdfUrl }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="内容"
          >
            <template #default="{row}">
              {{ row.content }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="创建时间"
          >
            <template #default="{row}">
              {{ row.createdTime }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="更新时间"
          >
            <template #default="{row}">
              {{ row.updatedTime }}
            </template>
          </el-table-column>
          <el-table-column
            width="100"
            fixed="right"
            label="操作"
          >
            <template #default="{row}">
              <el-button type="danger" size="mini" @click="handlerDel(row)">删除</el-button>
            </template>
          </el-table-column>

        </el-table>
      </el-col>
      <el-col :span="24" class="mt-2 flex justify-center" style="margin-top: 10px;display: flex;justify-content: end">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParam.pageNum"
          :page-sizes="[5,10,20]"
          :page-size="queryParam.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import api from '@/api/users'

export default {
  name: 'index',
  data() {
    return {
      total: 0,
      tableData: [],
      currentTab: 1,
      queryParam: {
        searchType: '',
        keyword: '',
        type: '',
        pageSize: 5,
        pageNum: 1
      }
    }
  },
  mounted() {
    (async() => {
      await this.fetchData('')
    })()
  },
  methods: {
    handlerDel(row){
      api.xing_zheng_gong_kai_del(row.id).then(()=>{
        this.$notify.success({
          title: '提示',
          message: '操作成功'
        })
        this.fetchData()
      })
    },
    handlerAdd() {
      this.$router.push("/gongkai/gongkai/add")
    },
    handlerSearch() {
      this.queryParam.pageNum = 1
      this.tableData = []
      this.total = 0
      this.fetchData()
    },
    async fetchData(type, index) {
      let { data } = await api.xing_zheng_gong_kai({ ...this.queryParam, type })
      console.log('>>>>>>>>>>>>>>>>>数据', data.records)
      this.tableData = data.records
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>
<style scoped lang="scss">
//@tailwind base;
//@tailwind components;
//@tailwind utilities;
</style>
